import ProductThumbnailName from "../../components/ProductThumbnailName";

//判断是否已发货信息
export const getReFundInfo = (order_have_send_spec_ids: any[], productItem: any) => {
	if (!order_have_send_spec_ids || !productItem) {
		return {
			hasBeenShipped: false,
			label: "-"
		};
	}

	const flag = order_have_send_spec_ids?.indexOf(productItem?.spec_snapshot?.spec_id) > -1;

	return {
		hasBeenShipped: flag,
		label: flag ? "已发货" : "待发货"
	};
};

export const getTableColumns = (data: any) => {
	return [
		{
			title: "店铺",
			dataIndex: "shop1",
			width: 200,
			render: () => data?.shop_info?.shop_name ?? "-"
		},
		{
			title: "商品",
			dataIndex: "shop2",
			width: 200,
			render: (_, record) => <ProductThumbnailName data={[record]} />
		},
		// {
		// 	title: "状态",
		// 	dataIndex: "shop3",
		// 	width: 140,
		// 	// renderText: () => data?.status_info?.order_status_name ?? "-"
		// 	render: (_, record: any) => {
		// 		return getReFundInfo(data?.order_have_send_spec_ids, record)?.label;
		// 	}
		// },
		{
			title: "单价",
			dataIndex: "format_spec_price",
			width: 140,
			renderText: v => `￥${v}`
		},
		{
			title: "数量",
			dataIndex: "spec_num",
			width: 140
		},
		{
			title: "优惠",
			dataIndex: "format_spec_discount_price",
			width: 140,
			renderText: v => `￥${v}`
		},
		{
			title: "实收款",
			dataIndex: "format_spec_total_price",
			width: 140,
			render: (_, record) => {
				console.log(record, '<=========record')
				return (
					<>
						<div>{`￥${record.format_spec_total_price}`}</div>
						{/* <div>（含快递费:{`￥${data.format_total_shipping_fee}`}）</div> */}
					</>
				);
			}
		}
	];
};
